<template>
  <div style="height: 30px"></div>
  <el-button @click="show = true">显示模态框</el-button>
  <teleport to="body">
    <div class="mask" v-if="show" @click="show = false">
      <h1 style="color: pink">hello teleport</h1>
    </div>
  </teleport>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
export default defineComponent({
  setup () {
    const show = ref(false)
    return {
      show
    }
  }
})
</script>

<style lang="scss" scoped>
  .mask {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
  }
</style>